package cfdt.ldl.web.controller.user;

import cfdt.common.exception.CodeException;
import cfdt.common.vo.ObjectBaseResponse;
import cfdt.ldl.web.api.request.LoginWebRequest;
import cfdt.ldl.web.api.response.LoginWebResponse;
import cfdt.ldl.web.service.account.LoginWebService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@Tag(name = "登录控制器", description = "登录相关接口")
@RestController
@RequestMapping("/user/login")
public class LoginWebController {

    @Autowired
    LoginWebService loginWebService;

    @Operation(summary = "执行登录操作", description = "执行登录操作，响应Token")
    @ResponseBody
    @PostMapping("/doLogin")
    public ObjectBaseResponse<LoginWebResponse> login(HttpServletRequest request, @RequestBody @Valid LoginWebRequest loginWebRequest) throws CodeException {
        return loginWebService.login(loginWebRequest);
    }



}
